package com.gaswell.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gaswell.entity.Qba01;
import com.gaswell.entity.Qba01M;
import com.gaswell.vo.Qba01Vo2;
import com.gaswell.vo.TestVo;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.ResultSetType;
import org.apache.ibatis.session.ResultHandler;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.sql.Timestamp;
import java.util.List;

/**
 * <p>
 * 采气井日数据 Mapper 接口
 * </p>
 *
 * @author Lei Wang
 * @since 2022-05-24
 */
@Repository

public interface Qba01Mapper extends EasyBaseMapper<Qba01> {
    @Select("select * from qba01 order by rq desc limit 1")
    Qba01 selectLastOne();

    @Select("${sql}")
    @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 1000)
    @ResultType(Qba01.class)
    void streamQuery(@Param("sql") String sql, ResultHandler<Qba01> handler);

    @Select("select * from (select * from qba01 where jh=#{ywbh} or jh=#{zwbh} order by rq desc) where rownum=1")
    Qba01 getLatest(@Param("ywbh") String ywbh, @Param("zwbh") String zwbh);

    List<Qba01> getLatestForList(@Param("ywbh") List<String> ywbh, @Param("zwbh") List<String> zwbh);

//    List<Qba01> GetByDateLast(List<String> zwbhs, List<String> ywbhs);

    IPage<Qba01Vo2>  getByPropertiesDirectSingleThread (IPage page, Timestamp start, String end, String type, String jh, int sort,
                                                        Integer sfsjh, List<String> ywbhs, List<String> zwbhs);
    List<TestVo> test();


//    Cursor<Qba01> streamQuery();

}
